function type(x){
    let res = Object.prototype.toString.call(x)  
    return res.slice(8, res.length - 1)     // '[object String]'
}

console.log(type('Damn'));  // String
console.log(type(123));     // Number
console.log(type([]));      // Array